/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.dao.trace;

import java.io.Serializable;
import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import com.jili.ubert.code.CodeTool;
import java.io.IOException;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dragon
 */
@Entity
@Table(name = "trace_work_group")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TraceWorkGroup.findAll", query = "SELECT t FROM TraceWorkGroup t"),
    @NamedQuery(name = "TraceWorkGroup.findBySid", query = "SELECT t FROM TraceWorkGroup t WHERE t.sid = :sid"),
    @NamedQuery(name = "TraceWorkGroup.findByTraceType", query = "SELECT t FROM TraceWorkGroup t WHERE t.traceType = :traceType"),
    @NamedQuery(name = "TraceWorkGroup.findByGroupID", query = "SELECT t FROM TraceWorkGroup t WHERE t.groupID = :groupID"),
    @NamedQuery(name = "TraceWorkGroup.findByGroupName", query = "SELECT t FROM TraceWorkGroup t WHERE t.groupName = :groupName"),
    @NamedQuery(name = "TraceWorkGroup.findByManagerUserID", query = "SELECT t FROM TraceWorkGroup t WHERE t.managerUserID = :managerUserID"),
    @NamedQuery(name = "TraceWorkGroup.findByType", query = "SELECT t FROM TraceWorkGroup t WHERE t.type = :type"),
    @NamedQuery(name = "TraceWorkGroup.findByUpGroupID", query = "SELECT t FROM TraceWorkGroup t WHERE t.upGroupID = :upGroupID"),
    @NamedQuery(name = "TraceWorkGroup.findByFlag", query = "SELECT t FROM TraceWorkGroup t WHERE t.flag = :flag"),
    @NamedQuery(name = "TraceWorkGroup.findByRole", query = "SELECT t FROM TraceWorkGroup t WHERE t.role = :role"),
    @NamedQuery(name = "TraceWorkGroup.findByOwnUserID", query = "SELECT t FROM TraceWorkGroup t WHERE t.ownUserID = :ownUserID"),
    @NamedQuery(name = "TraceWorkGroup.findByAlterUserID", query = "SELECT t FROM TraceWorkGroup t WHERE t.alterUserID = :alterUserID"),
    @NamedQuery(name = "TraceWorkGroup.findByCreateTime", query = "SELECT t FROM TraceWorkGroup t WHERE t.createTime = :createTime"),
    @NamedQuery(name = "TraceWorkGroup.findByTimeStamp", query = "SELECT t FROM TraceWorkGroup t WHERE t.timeStamp = :timeStamp")})
public class TraceWorkGroup implements Serializable {
	public static byte[] EnCode(TraceWorkGroup msg) throws IOException {
		Codec<TraceWorkGroup> Lcode = ProtobufProxy.create(TraceWorkGroup.class);
		return Lcode.encode(msg);
	}
	public static TraceWorkGroup DeCode(byte[] data) throws IOException {
	Codec<TraceWorkGroup> Lcode = ProtobufProxy.create(TraceWorkGroup.class);
		return Lcode.decode(data);
	}

    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "sid")
    @Protobuf
	private Integer sid;
    @Basic(optional = false)
    @Column(name = "TraceType")
    @Protobuf
	private String traceType;
    @Basic(optional = false)
    @Column(name = "GroupID")
    @Protobuf
	private int groupID;
    @Column(name = "GroupName")
    private String groupName;
	@Protobuf
	private byte[] groupNameBit;
    @Column(name = "ManagerUserID")
    @Protobuf
	private String managerUserID;
    @Column(name = "Type")
    @Protobuf
	private String type;
    @Column(name = "UpGroupID")
    @Protobuf
	private Integer upGroupID;
    @Column(name = "Flag")
    @Protobuf
	private String flag;
    @Column(name = "Role")
    @Protobuf
	private String role;
    @Column(name = "OwnUserID")
    @Protobuf
	private String ownUserID;
    @Column(name = "AlterUserID")
    @Protobuf
	private String alterUserID;
    @Column(name = "CreateTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
	//@Protobuf
//tprivate long createTimeL;
    @Column(name = "TimeStamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
	//@Protobuf
	//private long timeStampL;

    public TraceWorkGroup() {
    }

    public TraceWorkGroup(Integer sid) {
        this.sid = sid;
    }

    public TraceWorkGroup(Integer sid, String traceType, int groupID) {
        this.sid = sid;
        this.traceType = traceType;
        this.groupID = groupID;
    }

    public Integer getSid() {
        return sid;
    }

    public void setSid(Integer sid) {
        this.sid = sid;
    }

    public String getTraceType() {
        return traceType;
    }

    public void setTraceType(String traceType) {
        this.traceType = traceType;
    }

    public int getGroupID() {
        return groupID;
    }

    public void setGroupID(int groupID) {
        this.groupID = groupID;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
        this.setGroupNameBit(CodeTool.StringToBit(groupName));
    }

    public String getManagerUserID() {
        return managerUserID;
    }

    public void setManagerUserID(String managerUserID) {
        this.managerUserID = managerUserID;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Integer getUpGroupID() {
        return upGroupID;
    }

    public void setUpGroupID(Integer upGroupID) {
        this.upGroupID = upGroupID;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public String getOwnUserID() {
        return ownUserID;
    }

    public void setOwnUserID(String ownUserID) {
        this.ownUserID = ownUserID;
    }

    public String getAlterUserID() {
        return alterUserID;
    }

    public void setAlterUserID(String alterUserID) {
        this.alterUserID = alterUserID;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
		//this.createTimeL = CodeTool.DateToLong(createTime);
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
		//this.timeStampL = CodeTool.DateToLong(timeStamp);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sid != null ? sid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TraceWorkGroup)) {
            return false;
        }
        TraceWorkGroup other = (TraceWorkGroup) object;
        if ((this.sid == null && other.sid != null) || (this.sid != null && !this.sid.equals(other.sid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jili.ubert.dao.trace.TraceWorkGroup[ sid=" + sid + " ]";
    }

    public byte[] getGroupNameBit() {
        return groupNameBit;
    }

    public void setGroupNameBit(byte[] groupNameBit) {
        this.groupNameBit = groupNameBit;
		this.groupName = CodeTool.BitToString(groupNameBit);
    }
    
}
